﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace SimplexEngine
{
    public class MRTNormalMapMaterial : MRTBasicMaterial
    {
        public MRTNormalMapMaterial()
        {
            effect = Root.Instance.ContentSystem.GetResource("MRT.Shader");
            technique_name = "NormalMap";
        }

        protected override void OnApplyParameters(GameTime game_time, Int64 frame_number)
        {
            base.OnApplyParameters(game_time, frame_number);
            Effect.Parameters["NormalTexture"].SetValue(NormalTexture.Texture);
            ApplyBasicParameters(game_time, frame_number);
        }

        public override void SetParameters(Dictionary<String, Object> parameters) 
        {
            base.SetParameters(parameters);
            if (parameters.ContainsKey("NormalTexture"))
                normal_texture = parameters["NormalTexture"] as MaterialTexture;
        }

        public override Dictionary<String, Object> GetParameters()
        {
            Dictionary<String, Object> parameters = base.GetParameters();
            parameters.Add("NormalTexture", NormalTexture);

            return parameters; ;
        }

        public MaterialTexture NormalTexture { get { return normal_texture; } }
        protected MaterialTexture normal_texture = new MaterialTexture();

        public override Material Clone()
        {
            MRTNormalMapMaterial material = new MRTNormalMapMaterial();
            material.diffuse_texture = diffuse_texture;
            material.normal_texture = normal_texture;
            return material;
        }
    }
}
